#include<bits/stdc++.h>
using namespace std;
string s1 , s2;
void dfs(int l1 , int r1 , int l2 , int r2){
	if(l1 > r1 || l2 > r2){
		return;
	}
	int m = s2.find(s1[l1]);
	dfs(l1 + 1 , l1 + m - l2 , l2 , m - 1);
	dfs(l1 + m - l2 + 1 , r1 , m + 1 , r2);
	cout << s1[l1];
}
int main(){
	cin >> s2 >> s1;
	int r1 = s1.length() - 1;
	int r2 = s2.length() - 1;
	dfs(0 , r1 , 0 , r2);
	return 0;
}
